package com.hangim.pce.common.search.enums;

/**
 * ElasticSearch实体类型
 */
public enum ESEntityType {
    DEFAULT("default", "默认实体类型"),
    DRUG("drug", "药品"),
    ELEMENT("element", "成分"),
    DISEASE("disease", "疾病"),
    SYMPTOM("symptom", "症状");

    // 实体类型
    private final String code;
    // 描述
    private final String desc;

    ESEntityType(final String code, final String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ESEntityType getESEntityType(String code) {
        ESEntityType[] ts = ESEntityType.values();
        for (ESEntityType t : ts) {
            if (t.getCode().equalsIgnoreCase(code)) {
                return t;
            }
        }
        return DEFAULT;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
